package com.ruoyi.flink.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flink.domain.JobAlarmConfig;
import com.ruoyi.flink.service.IJobAlarmConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 告警辅助配置Controller
 * 
 * @author shu_k
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/flink/JobAlarmConfig")
public class JobAlarmConfigController extends BaseController
{
    @Autowired
    private IJobAlarmConfigService jobAlarmConfigService;

    /**
     * 查询告警辅助配置列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobAlarmConfig jobAlarmConfig)
    {
        startPage();
        List<JobAlarmConfig> list = jobAlarmConfigService.selectJobAlarmConfigList(jobAlarmConfig);
        return getDataTable(list);
    }

    /**
     * 导出告警辅助配置列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:export')")
    @Log(title = "告警辅助配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JobAlarmConfig jobAlarmConfig)
    {
        List<JobAlarmConfig> list = jobAlarmConfigService.selectJobAlarmConfigList(jobAlarmConfig);
        ExcelUtil<JobAlarmConfig> util = new ExcelUtil<JobAlarmConfig>(JobAlarmConfig.class);
        return util.exportExcel(list, "告警辅助配置数据");
    }

    /**
     * 获取告警辅助配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jobAlarmConfigService.selectJobAlarmConfigById(id));
    }

    /**
     * 新增告警辅助配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:add')")
    @Log(title = "告警辅助配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobAlarmConfig jobAlarmConfig)
    {
        return toAjax(jobAlarmConfigService.insertJobAlarmConfig(jobAlarmConfig));
    }

    /**
     * 修改告警辅助配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:edit')")
    @Log(title = "告警辅助配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobAlarmConfig jobAlarmConfig)
    {
        return toAjax(jobAlarmConfigService.updateJobAlarmConfig(jobAlarmConfig));
    }

    /**
     * 删除告警辅助配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobAlarmConfig:remove')")
    @Log(title = "告警辅助配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jobAlarmConfigService.deleteJobAlarmConfigByIds(ids));
    }
}
